package com.java.polymorphic;

/**
 * @author Lenl
 * @create 2021-05-30 0:56
 */
public class AnimalTest {
    public static void main(String[] args) {
        //多态的意义
        AnimalTest test=new AnimalTest();
        test.func(new Dog());
        test.func(new Cat());
    }


    public void func(Animal animal){
        animal.eat();
        animal.shout();
    }
}

class Animal{
    public void eat(){
        System.out.println("动物：进食");
    }
    public  void shout(){
        System.out.println("动物：叫");
    }
}

class Dog extends  Animal{
    @Override
    public void eat() {
        System.out.println("狗：吃骨头");
    }

    @Override
    public void shout() {
        System.out.println("狗：汪汪汪");
    }

}

class Cat extends  Animal{
    @Override
    public void eat() {
        System.out.println("猫：吃鱼");
    }

    @Override
    public void shout() {
        System.out.println("猫：喵喵喵");
    }
}
